package geometric3D;

public class yLineSegment extends LineSegment {
	
	public yLineSegment(Point startPoint, Point endPoint) {
		super();
		if(startPoint.getY()>endPoint.getY()){
			this.startPoint = endPoint;
			this.endPoint = startPoint;
		}else{
			this.startPoint = startPoint;
			this.endPoint = endPoint;
		}
		this.length = Math.abs(startPoint.getY()-endPoint.getY());
		
	}

	public yLineSegment(Point startPoint, int length,
			boolean isPositiveProjected) {
		super(length);
		if(isPositiveProjected){
			this.startPoint =startPoint;
			this.endPoint = new Point(this.startPoint.getX(), 
					this.startPoint.getY()+length, this.startPoint.getZ());
		}else{
			this.endPoint =startPoint;
			this.startPoint = new Point(startPoint.getX(), 
					startPoint.getY()-length, startPoint.getZ());
		}

	}

	@Override
	public Point getEndPoint() {
		return this.endPoint;
		
	}

	@Override	
	public Point getStartPoint() {
		
		return this.startPoint;
	}

	@Override
	public String toString() {
		return "yLineSegment [startPoint=" + startPoint + ", endPoint="
				+ endPoint + ", length=" + length + "]";
	}
	
	@Override
	public boolean isInLineSegment(Point point) {
		if(point.getX() != startPoint.getX() 
				|| point.getZ() != startPoint.getZ()
				|| point.getY() < startPoint.getY()
				|| point.getY()> endPoint.getY()){
			return false;
		}
		return true;
	}

	
}
